package com.dries.portal.browser.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/9/16 17:08
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements UserDetails {

    private Integer customerId;
    /**
     * 用户登录名
     */
    private String userName;
    /**
     * 密码
     */
    private String password;

    private String openId;

    private String unionId;
    /**
     * 账户是否可用 0 不可用 1 可用
     */
    private Integer accEnable;
    /**
     * 账户是否锁定 0 未锁定 1 锁定
     */
    private Integer accLocked;
    /**
     * 账户是否过期 0 未过期 1 已过期
     */
    private Integer accExpired;
    /**
     * 密码是否过期 0 未过期 1 已过期
     */
    private Integer pwExpired;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getUsername() {
        return userName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accExpired == 0;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accLocked == 0;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return pwExpired == 0;
    }

    @Override
    public boolean isEnabled() {
        return accEnable == 1;
    }
}
